<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      box-sizing: border-box;
      list-style-type: none;
    }
    body {
      display: flex;
      justify-content: center;
      align-items: center;
      margin: 0;
      height: 100vh;
      background-color: #eafbff;
      background-image: linear-gradient(to bottom, 
      #eafbff 0%,
      #eafbff 50%,
      #5290f9 50%,
      #5290f9 100%
      );
    }
    nav {
      display: flex;
      justify-content: center;
      align-items: center;
      transition: width 0.6s linear;
      overflow-x: hidden;
      border-radius: 3px;
      box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3);
      width: 80px;
      padding: 20px;
      background-color: #fff;
    }
    nav.active {
      width: 350px;
    }
    ul {
      display: flex;
      width: 0;
      margin: 0;
      padding: 0;
      transition: width 0.6s linear;
    }
    nav.active ul {
      width: 100%;
    }
    nav ul li {
      transform: rotateY(0deg);
      opacity: 0;
      transition: transform 0.6s linear;
    }
    nav ul a {
      position: relative;
      color: #000;
      text-decoration: none;
      margin: 0 10px;
    }
    nav.active ul li {
      opacity: 1;
      transform: rotateY(360deg);
    }
    .icon {
      position: relative;
      width: 30px;
      height: 30px;
      border: 0;
      cursor: pointer;
      padding: 0;
      background-color: #fff;
    }
    .icon .line {
      position: absolute;
      top: 10px;
      left: 5px;
      background-color: #5290f9;
      height: 2px;
      width: 20px;
      transition: transform 0.6s linear;
    }
    .icon .line2 {
      top: auto;
      bottom: 10px;
    }
    nav.active .icon .line1 {
      transform: rotate(765deg) translateY(5.5px);
    }
    nav.active .icon .line2 {
      transform: rotate(-765deg) translateY(-5.5px);
    }
  </style>
</head>
<body>
  <nav class="active" id="nav">
    <ul>
      <li><a href="#">Home</a></li>
      <li><a href="#">Works</a></li>
      <li><a href="#">About</a></li>
      <li><a href="#">Contact</a></li>
    </ul>
    <button class="icon" id="toggle">
      <div class="line line1"></div>
      <div class="line line2"></div>
    </button>
  </nav>

  <script>
    const toggle = document.getElementById("toggle");
    const nav = document.getElementById("nav");
    
    toggle.addEventListener("click", () => {
      nav.classList.toggle("active");
    });
  </script>
</body>
</html>